W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
A binary tree can either be empty or consist of one vertex, with two trees linked to it. These two trees are called a left and a right subtree. In each vertex there is one letter from the English alphabet. The vertex which is not a subtree of any vertex, is called a root. We say that a tree is a Binary Search Tree (BST) if for each vertex the following condition is satisfied: all letters in the left subtree precede in alphabetical order the letter in the root, and all letters from the right subtree follow the letter in the root. A code of a BST is:
There are exactly fourteen 4-vertex BSTs. These are (in alphabetical order):
The string badc is the (7,4)-code and it corresponds to the BST printed below:
Write a program which:
In the first and only line of the standard input there are exactly two positive integers and , separated by a single space, . The number is not greater than the number of codes of BST with vertices.
In the first and only line of the standard output there should be exactly one word (written in small letters) being the -code.
For the input data:
11 4
the correct result is:
dacb
Task author: Wojciech Guzicki.